package com.yanmaohu.yulia.statement;

import com.yanmaohu.yulia.bean.*;

/**
 * @author Bright Lee
 */
public final class MergeStatement implements SqlDataChangeStatement, Statement {

    private int beginIndex;
    private int endIndex;
    private TargetTable targetTable;
    private Identifier mergeCorrelationName;
    private TableReference tableReference;
    private BooleanValueExpression searchCondition;
    private MergeWhenClause mergeOperationSpecification;

    public MergeStatement(int beginIndex,
                          TargetTable targetTable,
                          Identifier mergeCorrelationName,
                          TableReference tableReference,
                          BooleanValueExpression searchCondition,
                          MergeWhenClause mergeOperationSpecification) {
        this.beginIndex = beginIndex;
        this.endIndex = mergeOperationSpecification.getEndIndex();
        this.targetTable = targetTable;
        this.mergeCorrelationName = mergeCorrelationName;
        this.tableReference = tableReference;
        this.searchCondition = searchCondition;
        this.mergeOperationSpecification = mergeOperationSpecification;
    }

    @Override
    public int getBeginIndex() {
        return beginIndex;
    }

    @Override
    public int getEndIndex() {
        return endIndex;
    }

    public TargetTable getTargetTable() {
        return targetTable;
    }

    public Identifier getMergeCorrelationName() {
        return mergeCorrelationName;
    }

    public TableReference getTableReference() {
        return tableReference;
    }

    public BooleanValueExpression getSearchCondition() {
        return searchCondition;
    }

    public MergeWhenClause getMergeOperationSpecification() {
        return mergeOperationSpecification;
    }

}
